local fuhen = fk.CreateSkill{
  name = "lingling__fuhen",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["lingling__fuhen"] = "覆恨",
  [":lingling__fuhen"] = "锁定技，当你回复体力后，你随机对一名对你造成过伤害的角色造成1点伤害，若其已死亡，你失去此技能。",

  ["#lingling__fuhen"] = "%to 竖子，复能言否？",
}

fuhen:addEffect(fk.HpRecover, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(fuhen.name) and
      #player.room.logic:getActualDamageEvents(1, function (e)
        return e.data.from ~= nil and e.data.to == player
      end, Player.HistoryGame) > 0
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local targets = {}
    room.logic:getActualDamageEvents(1, function (e)
      local damage = e.data
      if damage.from ~= nil and damage.to == player then
        table.insertIfNeed(targets, damage.from)
      end
    end, Player.HistoryGame)
    local to = table.random(targets)
    room:doIndicate(player, {to})
    player:broadcastSkillInvoke(fuhen.name)
    if to.dead then
      room:handleAddLoseSkills(player, "-lingling__fuhen")
      room:doIndicate(player, {to})
      room:broadcastPlaySound("./audio/system/normal_damage2")
      room:sendLog{
        type = "#lingling__fuhen",
        from = player.id,
        to = {to.id},
        toast = true,
      }
    else
      room:damage {
        from = player,
        to = to,
        damage = 1,
        skillName = fuhen.name
      }
    end
  end,
})

return fuhen
